package com.rmy.queue.controller;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.rmy.queue.domain.QmsErpRule;
import com.rmy.queue.domain.QmsWindowInfo;
import com.rmy.queue.service.IQmsErpRuleService;
import com.rmy.queue.service.IQmsWindowInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.rmy.common.annotation.Log;
import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.AjaxResult;
import com.rmy.common.enums.BusinessType;
import com.rmy.queue.domain.QmsWindowBusiness;
import com.rmy.queue.service.IQmsWindowBusinessService;
import com.rmy.common.utils.poi.ExcelUtil;
import com.rmy.common.core.page.TableDataInfo;

/**
 * 窗口业务Controller
 * 
 * @author rmy
 * @date 2022-09-30
 */
@RestController
@RequestMapping("/queue/windowbusiness")
public class QmsWindowBusinessController extends BaseController
{
    @Autowired
    private IQmsWindowBusinessService qmsWindowBusinessService;



    /**
     * 查询窗口业务列表
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:list')")
    @GetMapping("/list")
    public TableDataInfo list(QmsWindowBusiness qmsWindowBusiness)
    {
        startPage();
        List<QmsWindowBusiness> list = qmsWindowBusinessService.selectQmsWindowBusinessList(qmsWindowBusiness);
        return getDataTable(list);
    }

    /**
     * 导出窗口业务列表
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:export')")
    @Log(title = "窗口业务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmsWindowBusiness qmsWindowBusiness)
    {
        List<QmsWindowBusiness> list = qmsWindowBusinessService.selectQmsWindowBusinessList(qmsWindowBusiness);
        ExcelUtil<QmsWindowBusiness> util = new ExcelUtil<QmsWindowBusiness>(QmsWindowBusiness.class);
        util.exportExcel(response, list, "窗口业务数据");
    }

    /**
     * 获取窗口业务详细信息
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:query')")
    @GetMapping(value = "/{windowId}")
    public AjaxResult getInfo(@PathVariable("windowId") Long windowId)
    {
        return AjaxResult.success(qmsWindowBusinessService.selectQmsWindowBusinessByWindowId(windowId));
    }

    /**
     * 新增窗口业务
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:add')")
    @Log(title = "窗口业务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmsWindowBusiness qmsWindowBusiness)
    {
        return toAjax(qmsWindowBusinessService.insertQmsWindowBusiness(qmsWindowBusiness));
    }

    /**
     * 修改窗口业务
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:edit')")
    @Log(title = "窗口业务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmsWindowBusiness qmsWindowBusiness)
    {
        return toAjax(qmsWindowBusinessService.updateQmsWindowBusiness(qmsWindowBusiness));
    }

    /**
     * 删除窗口业务
     */
    @PreAuthorize("@ss.hasPermi('queue:windowbusiness:remove')")
    @Log(title = "窗口业务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{windowIds}")
    public AjaxResult remove(@PathVariable Long[] windowIds)
    {
        return toAjax(qmsWindowBusinessService.deleteQmsWindowBusinessByWindowIds(windowIds));
    }

}
